<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="证券代码" prop="seccode">
        <el-input v-model="queryParams.seccode" placeholder="请输入证券代码" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="证券简称" prop="secname">
        <el-input v-model="queryParams.secname" placeholder="请输入证券简称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="英文名称" prop="f001v">
        <el-input v-model="queryParams.f001v" placeholder="请输入英文名称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="英文简称" prop="f002v">
        <el-input v-model="queryParams.f002v" placeholder="请输入英文简称" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="法人代表" prop="f003v">
        <el-input v-model="queryParams.f003v" placeholder="请输入法人代表" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item label="注册地址" prop="f004v">
        <el-input v-model="queryParams.f004v" placeholder="请输入注册地址" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
                   v-hasPermi="['invest:gs-base:create']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                   v-hasPermi="['invest:gs-base:export']">导出</el-button>
      </el-col>
              <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

            <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
            <!-- <el-table-column label="机构ID" align="center" prop="orgid" />
      <el-table-column label="机构名称" align="center" prop="orgname" /> -->
      <el-table-column label="证券代码" align="center" prop="seccode" />
      <el-table-column label="证券简称" align="center" prop="secname" />
      <!-- <el-table-column label="英文名称" align="center" prop="f001v" />
      <el-table-column label="英文简称" align="center" prop="f002v" />
      <el-table-column label="法人代表" align="center" prop="f003v" />
      <el-table-column label="注册地址" align="center" prop="f004v" />
      <el-table-column label="办公地址" align="center" prop="f005v" />
      <el-table-column label="邮政编码" align="center" prop="f006v" />
      <el-table-column label="注册资金" align="center" prop="f007n" />
      <el-table-column label="货币编码" align="center" prop="f008v" />
      <el-table-column label="货币名称" align="center" prop="f009v" /> -->
      <el-table-column label="成立日期" align="center" prop="f010d" />
      <!-- <el-table-column label="机构网址" align="center" prop="f011v" />
      <el-table-column label="电子信箱" align="center" prop="f012v" />
      <el-table-column label="联系电话" align="center" prop="f013v" />
      <el-table-column label="联系传真" align="center" prop="f014v" />
      <el-table-column label="主营业务" align="center" prop="f015v" />
      <el-table-column label="经营范围" align="center" prop="f016v" />
      <el-table-column label="机构简介/公司成立概况" align="center" prop="f017v" />
      <el-table-column label="董事会秘书" align="center" prop="f018v" />
      <el-table-column label="董秘联系电话" align="center" prop="f019v" />
      <el-table-column label="董秘联系传真" align="center" prop="f020v" />
      <el-table-column label="董秘电子邮箱" align="center" prop="f021v" />
      <el-table-column label="证券事务代表" align="center" prop="f022v" />
      <el-table-column label="上市状态编码" align="center" prop="f023v" />
      <el-table-column label="上市状态" align="center" prop="f024v" />
      <el-table-column label="所属省份编码" align="center" prop="f025v" />
      <el-table-column label="所属省份" align="center" prop="f026v" />
      <el-table-column label="所属城市编码" align="center" prop="f027v" />
      <el-table-column label="所属城市" align="center" prop="f028v" /> -->
      <!-- <el-table-column label="中上协一级行业编码" align="center" prop="f029v" />
      <el-table-column label="中上协一级行业名称" align="center" prop="f030v" />
      <el-table-column label="中上协二级行业编码" align="center" prop="f031v" />
      <el-table-column label="中上协二级行业名称" align="center" prop="f032v" />
      <el-table-column label="申万行业分类一级编码" align="center" prop="f033v" />
      <el-table-column label="申万行业分类一级名称" align="center" prop="f034v" />
      <el-table-column label="申万行业分类二级编码" align="center" prop="f035v" />
      <el-table-column label="申万行业分类二级名称" align="center" prop="f036v" />
      <el-table-column label="申万行业分类三级编码" align="center" prop="f037v" />
      <el-table-column label="申万行业分类三级名称" align="center" prop="f038v" />
      <el-table-column label="会计师事务所" align="center" prop="f039v" />
      <el-table-column label="律师事务所" align="center" prop="f040v" /> -->
      <el-table-column label="董事长" align="center" prop="f041v" />
      <!-- <el-table-column label="总经理" align="center" prop="f042v" />
      <el-table-column label="公司独立董事(现任)" align="center" prop="f043v" />
      <el-table-column label="入选指数" align="center" prop="f044v" />
      <el-table-column label="最新报告预约日期" align="center" prop="f045v" />
      <el-table-column label="保荐机构" align="center" prop="f046v" />
      <el-table-column label="主承销商" align="center" prop="f047v" />
      <el-table-column label="PEVC标记" align="center" prop="f048v" />
      <el-table-column label="注册国家" align="center" prop="f049v" />
      <el-table-column label="统一社会信用代码" align="center" prop="f050v" />
      <el-table-column label="工商ID" align="center" prop="f051v" />
      <el-table-column label="可转债" align="center" prop="f052v" />
      <el-table-column label="CDR" align="center" prop="f053v" /> -->
      <el-table-column label="企业规模" align="center" prop="f054v" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template v-slot="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleInit(scope.row.seccode)"
                     v-hasPermi="['invest:juhcao:gsbase']">同步</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.seccode)"
                     v-hasPermi="['invest:gs-base:update']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
                     v-hasPermi="['invest:gs-base:delete']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
    <!-- 对话框(添加 / 修改) -->
    <GsBaseForm ref="formRef" @success="getList" />
    </div>
</template>

<script>
import * as GsBaseApi from '@/api/invest/gsbase';
import * as JuchaoApi from '@/api/invest/juchao';
import GsBaseForm from './GsBaseForm.vue';
export default {
  name: "GsBase",
  components: {
          GsBaseForm,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
              // 总条数
        total: 0,
      // 公司基本信息列表
      list: [],
      // 是否展开，默认全部展开
      isExpandAll: true,
      // 重新渲染表格状态
      refreshTable: true,
      // 选中行
      currentRow: {},
      // 查询参数
      queryParams: {
                    pageNo: 1,
            pageSize: 10,
        seccode: null,
        secname: null,
        f001v: null,
        f002v: null,
        f003v: null,
        f004v: null,
      },
            };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    async getList() {
      try {
      this.loading = true;
              const res = await GsBaseApi.getGsBasePage(this.queryParams);
        this.list = res.data.list;
        this.total = res.data.total;
      } finally {
        this.loading = false;
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 添加/修改操作 */
    openForm(id) {
      this.$refs["formRef"].open(id);
    },
    /** 删除按钮操作 */
    async handleDelete(row) {
      const seccode = row.seccode;
      await this.$modal.confirm('是否确认删除公司基本信息编号为"' + seccode + '"的数据项?')
      try {
       await GsBaseApi.deleteGsBase(seccode);
       await this.getList();
       this.$modal.msgSuccess("删除成功");
      } catch {}
    },
    /** 同步按钮操作 */
    async handleInit(seccode) {
      await this.$modal.confirm('是否确认同步公司基本信息编号为"' + seccode + '"的数据项?')
      try {
       await JuchaoApi.initGsBase(seccode);
       await this.getList();
       this.$modal.msgSuccess("同步成功");
      } catch {}
    },
    /** 导出按钮操作 */
    async handleExport() {
      await this.$modal.confirm('是否确认导出所有公司基本信息数据项?');
      try {
        this.exportLoading = true;
        const res = await GsBaseApi.exportGsBaseExcel(this.queryParams);
        this.$download.excel(res, '公司基本信息.xls');
      } catch {
      } finally {
        this.exportLoading = false;
      }
    },
              }
};
</script>
